package com.movie.modules.jf.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.movie.modules.jf.entity.BannerEntity;
import com.movie.modules.jf.service.BannerService;
import com.movie.common.utils.PageUtils;
import com.movie.common.utils.R;



/**
 * 轮播表
 *
 * @author kakarot
 * @email 532050892@qq.com
 * @date 2021-08-20 01:31:11
 */
@RestController
@RequestMapping("/sys/banner")
@Api(tags = "轮播接口")
public class BannerController {
    @Autowired
    private BannerService bannerService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("轮播分页")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bannerService.queryPage(params);
        return R.ok().put("data", page);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{bannerId}")
    @ApiOperation("轮播信息详情")
    public R info(@PathVariable("bannerId") Integer bannerId){
		BannerEntity banner = bannerService.getById(bannerId);
        return R.ok().put("data", banner);
    }

    /**
     * 保存
     */
    @PostMapping("/update")
    @ApiOperation("添加/修改轮播")
    public R update(@RequestBody BannerEntity banner){
		bannerService.saveOrUpdate(banner);
        return R.ok();
    }

    @PostMapping("/sort")
    @ApiOperation("修改轮播排序")
    public R sort(@RequestBody BannerEntity banner){
        bannerService.updateById(banner);
        return R.ok();
    }

    @PostMapping("/status")
    @ApiOperation("修改轮播状态")
    public R status(@RequestBody BannerEntity banner){
        bannerService.updateById(banner);
        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{bannerId}")
    @ApiOperation("删除轮播")
    public R delete(@PathVariable("bannerId") Integer bannerId){
        bannerService.removeById(bannerId);
        return R.ok();
    }

}
